package JPLXtandemGA;

import java.util.Random;

public class BooleanParameter implements IParameter<BooleanParameter> {
	
	final private Random RNG = new Random();
	final private boolean value;
	final private String name;
	
	public BooleanParameter( boolean value, String name ) {
		this.value = value;
		this.name = name;
	}

	@Override
	public BooleanParameter mutate() {
		return new BooleanParameter(!value, name);
	}

	@Override
	public String name() {
		return name;
	}

	@Override
	public BooleanParameter randomize() {
		return new BooleanParameter(RNG.nextBoolean(), name);
	}

	@Override
	public String xmlRepresentation() {
		String strValue = value ? "yes" : "no";
		return 	Parameters.makeNote(name, strValue);
	}

	@Override
	public String valueToString() {
		return value ? "yes" : "no";
	}
}
